package com.guardchina.framework.mybatis.datasource;

import com.guardchina.framework.mybatis.enu.DataSourceType;

/**
 * 描述：数据源选择
 *
 * @author lwb
 * @date 2019/3/22 9:18
 */
public class RoutingDataSourceContextHolder {

    private static ThreadLocal<DataSourceType> DATA_SOURCE_TYPE_HOLDER = new ThreadLocal<>();

    public static DataSourceType getDataSourceType(){
        return DATA_SOURCE_TYPE_HOLDER.get();
    }

    public static void setDataSourceType(DataSourceType dataSourceType){
        DATA_SOURCE_TYPE_HOLDER.set(dataSourceType);
    }

    public static void clearDataSourceType(){
        DATA_SOURCE_TYPE_HOLDER.remove();
    }
}
